package com.book.lizhi.ui;

import java.util.List;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.ActionBar;
import android.support.v7.app.ActionBarActivity;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;

import com.book.lizhi.R;
import com.book.lizhi.database.DataBaseMannager;
import com.book.lizhi.model.ArticleModel;
import com.book.lizhi.util.AppLog;

public class AboutActivity extends ActionBarActivity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_about);
		Toolbar toolbar = (Toolbar) findViewById(R.id.toobar);
		setSupportActionBar(toolbar);
		initUI();

		List<ArticleModel> infos = DataBaseMannager.getInstance().queryFavs(this);
		for (ArticleModel articleModel : infos) {
			AppLog.e(articleModel.id);
		}
	}

	private void initUI() {
		ActionBar actionBar = getSupportActionBar();
		actionBar.setDisplayHomeAsUpEnabled(true);
		actionBar.setTitle("关于");
		actionBar.setDisplayShowHomeEnabled(false);

		addOnClickListenner();
	}

	private void addOnClickListenner() {

		findViewById(R.id.about_email_view).setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {

				Intent data=new Intent(android.content.Intent.ACTION_SEND); 
				String[] email={"li_zhi_app@163.com"};
				data.putExtra(android.content.Intent.EXTRA_EMAIL, email);
				data.putExtra(Intent.EXTRA_SUBJECT, "联系励志应用"); 
				data.putExtra(Intent.EXTRA_TEXT, "我们需要和你做如下沟通:\n"); 
				data.setType("message/rfc822");
				startActivity(Intent.createChooser(data, "请选择邮件发送软件"));
			
			}
		});

	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		int id = item.getItemId();
		if (id == android.R.id.home) {
			finish();
			return true;
		}
		return super.onOptionsItemSelected(item);
	}
}
